package com.hx.vending.controller;

import com.hx.vending.annotation.Authorization;
import com.hx.vending.annotation.CurrentUserId;
import com.hx.vending.bean.SubsidiaryRole;
import com.hx.vending.service.ISubsidiaryRoleService;
import com.hx.vending.util.Msg;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

/**
 * Created by Administrator on 2019/3/12.
 */
@Controller
@RequestMapping("/subsidiaryRole")
public class SubsidiaryRoleController {

    @Autowired
    private ISubsidiaryRoleService subsidiaryRoleService;

    /**
     * 查询岗位
     * @param userId
     * @return
     */
    @RequestMapping("/selectSubsidiaryRole")
    @ResponseBody
    @Authorization
    public Msg selectSubsidiaryRole(@CurrentUserId Integer userId){
        return subsidiaryRoleService.selectSubsidiaryRole(userId);
    }

    /**
     * 添加岗位
     * @param subsidiaryRole
     * @param userId
     * @return
     */
    @RequestMapping("addSubsidiaryRole")
    @ResponseBody
    @Authorization
    public Msg addSubsidiaryRole(@RequestBody SubsidiaryRole subsidiaryRole,@CurrentUserId Integer userId){
        return subsidiaryRoleService.addSubsidiaryRole(subsidiaryRole,userId);
    }

    /**
     * 修改岗位
     * @param subsidiaryRole
     * @return
     */
    @RequestMapping("/updateSubsidiaryRole")
    @ResponseBody
    public Msg updateSubsidiaryRole(@RequestBody SubsidiaryRole subsidiaryRole){
        return subsidiaryRoleService.updateSubsidiaryRole(subsidiaryRole);
    }

    /**
     * 删除岗位
     * @param roleIds 多个用“-”隔开
     * @return
     */
    @RequestMapping(value = "/deleteSubsidiaryRole/{roleIds}",method = RequestMethod.DELETE)
    @ResponseBody
    public Msg deleteSubsidiaryRole(@PathVariable String roleIds){
        return subsidiaryRoleService.deleteSubsidiaryRole(roleIds);
    }

    /**
     * 查询岗位
     * @param subsidiaryRoleId
     * @return
     */
    @RequestMapping("/selectRoleByRoleId")
    @ResponseBody
    public Msg selectRoleByRoleId(Integer subsidiaryRoleId){
        return subsidiaryRoleService.selectRoleByRoleId(subsidiaryRoleId);
    }

}
